package com.fanfan.controller;

import com.fanfan.pojo.Pet;
import com.fanfan.pojo.domain.ResponseResult;
import com.fanfan.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/petList")
public class PetController {
    @Autowired
    PetService petService;
    @GetMapping
    public ResponseResult petList(Integer pageNum, Integer pageSize,Pet pet){
        return petService.petList(pageNum,pageSize,pet);
    }
    @GetMapping("/{id}")
    public ResponseResult petDetail(@PathVariable("id") Long petId){
        return petService.peDetail(petId);
    }
    @PostMapping
    public ResponseResult petAdd(@RequestBody Pet pet){
        return petService.petAdd(pet);
    }
    @DeleteMapping("/{id}")
    public ResponseResult petDel(@PathVariable Long id){
        petService.getBaseMapper().deleteById(id);
        return ResponseResult.okResult();
    }
    @PutMapping("/changeStatus")
    public ResponseResult petStatus(@RequestBody Pet pet){
        petService.updateById(pet);
        return ResponseResult.okResult();
    }
    @PutMapping
    public ResponseResult petUpdate(@RequestBody Pet pet){
        petService.updateById(pet);
        return ResponseResult.okResult();
    }

}
